@echo off
title SD WebUI Assistant

:: 检查是否安装了 Node.js
where node >nul 2>nul
if %errorlevel% neq 0 (
    echo Error: Node.js is not installed!
    echo Please install Node.js from https://nodejs.org/
    pause
    exit /b 1
)

:: 检查是否安装了 Python
where python >nul 2>nul
if %errorlevel% neq 0 (
    echo Error: Python is not installed!
    echo Please install Python from https://www.python.org/
    pause
    exit /b 1
)

:: 创建新的命令行窗口启动前端服务
cd web
start "Frontend Server" cmd /k "echo Starting Frontend Server... && npm install && npm run dev"

:: 创建新的命令行窗口启动后端服务
cd ../backend
start "Backend Server" cmd /k "echo Starting Backend Server... && python -m pip install -r requirements.txt && python main.py"

:: 等待3秒后打开浏览器
timeout /t 3 /nobreak
start http://localhost:5173

echo Services are starting...
echo Frontend: http://localhost:5173
echo Backend: http://localhost:5000
echo.
echo Press any key to exit...
pause >nul 